package cate.game.play.skill.passive.exp;

import cate.game.play.config.PlayCfgArgs;
import cate.game.play.proce.action.ctx.TimeActionCtx;
import cate.game.play.proce.move.MoveCtx;
import cate.game.play.skill.passive.PassiveHandler;

/**
 * 当自身生命值低于50%时破除自身除眩晕外所有负面效果,但造成伤害和治疗量额外降低25%，持续2回合,辅助不会受到此负面效果的影响，每场战斗仅可触发1次
 */
public class 心如止水PH extends PassiveHandler {

	private int 检测血量;

	private String 排除标签;

	private int buff;

	private byte 免疫职业;

	//检测血量=5000&排除标签=眩晕&buff=？&免疫职业=？？
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		检测血量 = args.getInt("检测血量", 0);
		排除标签 = args.get("排除标签");
		buff = args.getInt("buff", 0);
		免疫职业 = args.getByte("免疫职业", (byte)0);
	}

	private boolean add;

	@Override
	public void onMoveDone(MoveCtx move, TimeActionCtx action) {
		if (add) {
			return;
		}
		if (skill.owner.isDead()) {
			return;
		}
		if (skill.owner.attr.total().hpCurRate() >= 检测血量) {
			return;
		}
		add = true;
		skill.owner.buff.tryDispel(action, b -> !b.isGood() && !b.cfg.containTag(排除标签));
		if (skill.owner.getJob() != 免疫职业) {
			skill.owner.buff.tryAddByTid(action, buff);
		}
	}
}
